package cn.net.yugu.doraemon.api.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: wanghongli
 * @create: 2022-09-20 13:12:35
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MapResult<K, V> extends BaseResult {
    private Map<K, V> data;

    public Map<K, V> getData() {
        return this.data;
    }

    public void setData(Map<K, V> data) {
        this.data = data;
    }

    public MapResult<K, V> add(K key, V val) {
        if (this.data == null) {
            this.data = new HashMap<>();
        }
        this.data.put(key, val);
        return this;
    }
}
